#include "xincs.h"
#include "fxver.h"
#include "fxdefs.h"
#include "FXHash.h"
#include "FXStream.h"
#include "FXTextCodec.h"
#include "FX88597Codec.h"

namespace FX {

FXIMPLEMENT(FX88597Codec,FXTextCodec,NULL,0)


//// Created by codec tool on 03/25/2005 from: 8859-7.TXT ////
static const unsigned short forward_data[256]={
   0,    1,    2,    3,    4,    5,    6,    7,    8,    9,    10,   11,   12,   13,   14,   15,
   16,   17,   18,   19,   20,   21,   22,   23,   24,   25,   26,   27,   28,   29,   30,   31,
   32,   33,   34,   35,   36,   37,   38,   39,   40,   41,   42,   43,   44,   45,   46,   47,
   48,   49,   50,   51,   52,   53,   54,   55,   56,   57,   58,   59,   60,   61,   62,   63,
   64,   65,   66,   67,   68,   69,   70,   71,   72,   73,   74,   75,   76,   77,   78,   79,
   80,   81,   82,   83,   84,   85,   86,   87,   88,   89,   90,   91,   92,   93,   94,   95,
   96,   97,   98,   99,   100,  101,  102,  103,  104,  105,  106,  107,  108,  109,  110,  111,
   112,  113,  114,  115,  116,  117,  118,  119,  120,  121,  122,  123,  124,  125,  126,  127,
   128,  129,  130,  131,  132,  133,  134,  135,  136,  137,  138,  139,  140,  141,  142,  143,
   144,  145,  146,  147,  148,  149,  150,  151,  152,  153,  154,  155,  156,  157,  158,  159,
   160,  8216, 8217, 163,  8364, 8367, 166,  167,  168,  169,  890,  171,  172,  173,  65533, 8213,
   176,  177,  178,  179,  900,  901,  902,  183,  904,  905,  906,  187,  908,  189,  910,  911,
   912,  913,  914,  915,  916,  917,  918,  919,  920,  921,  922,  923,  924,  925,  926,  927,
   928,  929,  65533, 931,  932,  933,  934,  935,  936,  937,  938,  939,  940,  941,  942,  943,
   944,  945,  946,  947,  948,  949,  950,  951,  952,  953,  954,  955,  956,  957,  958,  959,
   960,  961,  962,  963,  964,  965,  966,  967,  968,  969,  970,  971,  972,  973,  974,  65533,
  };


static const unsigned char reverse_plane[17]={
  0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
  };

static const unsigned char reverse_pages[73]={
  0,  61, 61, 61, 61, 61, 61, 61, 124,61, 61, 61, 61, 61, 61, 61,
  61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
  61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
  61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
  61, 61, 61, 61, 61, 61, 61, 61, 61,
  };

static const unsigned short reverse_block[188]={
  0,   16,  32,  48,  64,  80,  96,  112, 128, 144, 160, 176, 190, 190, 190, 190,
  190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
  190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
  190, 190, 190, 190, 190, 190, 190, 196, 208, 224, 240, 256, 272, 190, 190, 190,
  190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
  190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
  190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
  190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 287, 190, 190,
  190, 190, 190, 190, 190, 190, 297, 190, 190, 190, 190, 190, 190, 190, 190, 190,
  190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
  190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
  190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
  };

static const unsigned char reverse_data[313]={
   0,    1,    2,    3,    4,    5,    6,    7,    8,    9,    10,   11,   12,   13,   14,   15,
   16,   17,   18,   19,   20,   21,   22,   23,   24,   25,   26,   27,   28,   29,   30,   31,
   32,   33,   34,   35,   36,   37,   38,   39,   40,   41,   42,   43,   44,   45,   46,   47,
   48,   49,   50,   51,   52,   53,   54,   55,   56,   57,   58,   59,   60,   61,   62,   63,
   64,   65,   66,   67,   68,   69,   70,   71,   72,   73,   74,   75,   76,   77,   78,   79,
   80,   81,   82,   83,   84,   85,   86,   87,   88,   89,   90,   91,   92,   93,   94,   95,
   96,   97,   98,   99,   100,  101,  102,  103,  104,  105,  106,  107,  108,  109,  110,  111,
   112,  113,  114,  115,  116,  117,  118,  119,  120,  121,  122,  123,  124,  125,  126,  127,
   128,  129,  130,  131,  132,  133,  134,  135,  136,  137,  138,  139,  140,  141,  142,  143,
   144,  145,  146,  147,  148,  149,  150,  151,  152,  153,  154,  155,  156,  157,  158,  159,
   160,  26,   26,   163,  26,   26,   166,  167,  168,  169,  26,   171,  172,  173,  26,   26,
   176,  177,  178,  179,  26,   26,   26,   183,  26,   26,   26,   187,  26,   189,  26,   26,
   26,   26,   26,   26,   26,   26,   26,   26,   26,   26,   26,   26,   26,   26,   170,  26,
   26,   26,   26,   26,   180,  181,  182,  26,   184,  185,  186,  26,   188,  26,   190,  191,
   192,  193,  194,  195,  196,  197,  198,  199,  200,  201,  202,  203,  204,  205,  206,  207,
   208,  209,  26,   211,  212,  213,  214,  215,  216,  217,  218,  219,  220,  221,  222,  223,
   224,  225,  226,  227,  228,  229,  230,  231,  232,  233,  234,  235,  236,  237,  238,  239,
   240,  241,  242,  243,  244,  245,  246,  247,  248,  249,  250,  251,  252,  253,  254,  26,
   26,   26,   26,   26,   175,  26,   26,   161,  162,  26,   26,   26,   26,   26,   26,   26,
   26,   26,   26,   26,   26,   164,  26,   26,   165,
  };


FXint FX88597Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const {
  if(nsrc<1) return -1;
  wc=forward_data[(FXuchar)src[0]];
  return 1;
  }


FXint FX88597Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const {
  if(ndst<1) return -1;
  dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)];
  return 1;
  }

FXint FX88597Codec::mibEnum() const {
  return 10;
  }


const FXchar* FX88597Codec::name() const {
  return "ISO-8859-7";
  }


const FXchar* FX88597Codec::mimeName() const {
  return "ISO-8859-7";
  }


const FXchar* const* FX88597Codec::aliases() const {
  static const FXchar *const list[]={"iso8859-7","ISO-8859-7","ISO_8859-7","greek","iso-ir-126","greek8","ELOT_928","ECMA-118",NULL};
  return list;
  }

}

